home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / FREENET / MELL / NETLIB00 / !NetLib / netinet / h / ip_icmp < prev    next >
Text File  |  1995-05-23  |  4KB  |  124 lines

  1. #ifndef __netinet_ip_icmp_h
  2. #define __netinet_ip_icmp_h
  3.  
  4. /* Freenet programmers interface - netinet/ip_icmp.h - 23/5/95 */
  5.  
  6. #include "sys/types.h"
  7. #include "netinet/ip.h"
  8. #include "netinet/in.h"
  9. #include "netinet/in_systm.h"
  10.  
  11. /*
  12.  * Interface Control Message Protocol Definitions.
  13.  * Per RFC 792, September 1981.
  14.  */
  15.  
  16. /*
  17.  * Structure of an icmp header.
  18.  */
  19. struct icmp {
  20.     u_char    icmp_type;        /* type of message, see below */
  21.     u_char    icmp_code;        /* type sub code */
  22.     u_short    icmp_cksum;        /* ones complement cksum of struct */
  23.     union {
  24.         u_char ih_pptr;            /* ICMP_PARAMPROB */
  25.         struct in_addr ih_gwaddr;    /* ICMP_REDIRECT */
  26.         struct ih_idseq {
  27.             n_short    icd_id;
  28.             n_short    icd_seq;
  29.         } ih_idseq;
  30.         int ih_void;
  31.  
  32.         /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
  33.         struct ih_pmtu {
  34.             n_short ipm_void;
  35.             n_short ipm_nextmtu;
  36.         } ih_pmtu;
  37.     } icmp_hun;
  38. #define    icmp_pptr    icmp_hun.ih_pptr
  39. #define    icmp_gwaddr    icmp_hun.ih_gwaddr
  40. #define    icmp_id        icmp_hun.ih_idseq.icd_id
  41. #define    icmp_seq    icmp_hun.ih_idseq.icd_seq
  42. #define    icmp_void    icmp_hun.ih_void
  43. #define    icmp_pmvoid    icmp_hun.ih_pmtu.ipm_void
  44. #define    icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
  45.     union {
  46.         struct id_ts {
  47.             n_time its_otime;
  48.             n_time its_rtime;
  49.             n_time its_ttime;
  50.         } id_ts;
  51.         struct id_ip  {
  52.             struct ip idi_ip;
  53.             /* options and then 64 bits of data */
  54.         } id_ip;
  55.         u_long    id_mask;
  56.         char    id_data[1];
  57.     } icmp_dun;
  58. #define    icmp_otime    icmp_dun.id_ts.its_otime
  59. #define    icmp_rtime    icmp_dun.id_ts.its_rtime
  60. #define    icmp_ttime    icmp_dun.id_ts.its_ttime
  61. #define    icmp_ip        icmp_dun.id_ip.idi_ip
  62. #define    icmp_mask    icmp_dun.id_mask
  63. #define    icmp_data    icmp_dun.id_data
  64. };
  65.  
  66. /*
  67.  * Minimum ICMP packet size
  68.  */
  69. #define    ICMP_MINLEN    8
  70. #define    ICMP_TSLEN    (8 + 3 * sizeof (n_time))    /* timestamp */
  71. #define    ICMP_MASKLEN    12                /* address mask */
  72. #define    ICMP_ADVLENMIN    (8 + sizeof (struct ip) + 8)    /* min */
  73. #define    ICMP_ADVLEN(p)    (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
  74.  
  75. /*
  76.  * Values for type and code fields
  77.  */
  78. #define ICMP_ECHOREPLY    0        /* Echo reply */
  79. #define ICMP_UNREACH      3        /* Destination unreachable */
  80. #define    ICMP_UNREACH_NET      0    /* Bad net */
  81. #define    ICMP_UNREACH_HOST     1    /* Bad host */
  82. #define    ICMP_UNREACH_PROTOCOL 2    /* Bad protocol */
  83. #define    ICMP_UNREACH_PORT     3    /* Bad port */
  84. #define    ICMP_UNREACH_NEEDFRAG 4    /* Fragmentation needed */
  85. #define    ICMP_UNREACH_SRCFAIL  5    /* Source route failed */
  86. #define    ICMP_UNREACH_NET_UNKNOWN 6    /* unknown net */
  87. #define    ICMP_UNREACH_HOST_UNKNOWN 7    /* unknown host */
  88. #define    ICMP_UNREACH_ISOLATED    8    /* src host isolated */
  89. #define    ICMP_UNREACH_NET_PROHIB    9    /* prohibited access */
  90. #define    ICMP_UNREACH_HOST_PROHIB 10    /* ditto */
  91. #define    ICMP_UNREACH_TOSNET    11    /* bad tos for net */
  92. #define    ICMP_UNREACH_TOSHOST    12    /* bad tos for host */
  93. #define ICMP_SOURCEQUENCH 4        /* Source quench */
  94. #define ICMP_REDIRECT     5        /* Redirection advice */
  95. #define    ICMP_REDIRECT_NET     0    /* For network */
  96. #define    ICMP_REDIRECT_HOST    1    /* For host */
  97. #define    ICMP_REDIRECT_TOSNET  2    /* For network and TOS */
  98. #define    ICMP_REDIRECT_TOSHOST 3    /* For host and TOS */
  99. #define ICMP_ECHO         8        /* Echo request */
  100. #define    ICMP_ROUTERADVERT    9    /* router advertisement */
  101. #define    ICMP_ROUTERSOLICIT    10    /* router solicitation */
  102. #define ICMP_TIMXCEED     11       /* Time exceeded */
  103. #define    ICMP_TIMXCEED_INTRANS 0    /* TTL exceeded */
  104. #define    ICMP_TIMXCEED_REASS   1    /* Reassembly timed out */
  105. #define ICMP_PARAMPROB    12       /* Parameter problem */
  106. #define    ICMP_PARAMPROB_OPTABSENT 1    /* req. opt. absent */
  107. #define ICMP_TSTAMP       13       /* Timestamp request */
  108. #define ICMP_TSTAMPREPLY  14       /* Timestamp reply */
  109. #define ICMP_IREQ         15       /* Information request */
  110. #define ICMP_IREQREPLY    16       /* Information reply */
  111. #define ICMP_MASKREQ      17       /* Address mask request */
  112. #define ICMP_MASKREPLY    18       /* Address mask reply */
  113.  
  114. #define    ICMP_MAXTYPE        18
  115.  
  116. #define    ICMP_INFOTYPE(type) \
  117.     ((type) == ICMP_ECHOREPLY || (type) == ICMP_ECHO || \
  118.     (type) == ICMP_ROUTERADVERT || (type) == ICMP_ROUTERSOLICIT || \
  119.     (type) == ICMP_TSTAMP || (type) == ICMP_TSTAMPREPLY || \
  120.     (type) == ICMP_IREQ || (type) == ICMP_IREQREPLY || \
  121.     (type) == ICMP_MASKREQ || (type) == ICMP_MASKREPLY)
  122.  
  123. #endif
  124.